<?php

namespace app\manager\model;

use think\Model;
use Carbon\Carbon;
use app\common\traits\model\TraitModel;

/**
 * 会员模块旅行币模型
 */
class Intergrates extends Model
{

    protected $table = 'integral_detail';
    const INTEGRAL_TO_MONEY_RATE = 1;
    const CURRENCYS =  'USD,CNY';
    protected static $user_model = 'CampManagers';
    
    use TraitModel;


    public function camps()
    {
        return $this->belongsTo('Camps','camp_id');
    }

    public function branchs()
    {
        return $this->belongsTo('Branchs','branch_id');
    }

    public function users()
    {
        return $this->belongsTo('Users','user_id');
    }



    public function getIntergratesLists($query = array(), $order = 'updated_at desc')
    {
        $user_id = self::getLoginUserInfo('id');
        $camp_id = model('CampManagers')->where('id',$user_id)->value('camp_id');
        return $this->getInfoList(array_merge($query, ['camp_id' => $camp_id, $order = 'created_at desc']));
    }
    
    /**
     * 获取登录用户积分
     * @return [type] [description]
     */
    public function getUserIntegral()
    {
        return self::getLoginUserInfo('integral');
    }

    


    
}
